package com.cpi.cornpp.futurepurchase.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;


/**
 * Customer Future Purchase Product List Action
 * @author Edgar Joao
 *
 */
public class CustomerFuturePurchaseProductListAction extends MappingDispatchAction{
	/** Identifier default workflow*/
	private final static String DEFAULT = "default";//$NON-NLS-1$
	/** Identifier default list of Customer Future Purchase*/
	//private List listCustomerFuturePurchaseProducts = null;//$NON-NLS-1$	
			
	
	/**
	 * 
	 * Go to Customer Future 
	 * Purchase Program List
	 * 
	 * Aqui se genera una sesion para
	 * la lista de productos
	 * 
	 * @author Edgar Joao
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward goCustomerFuturePurchaseProductList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  throws Exception{
		
		List listInSession = null;		
		HttpSession httpSession = null;				
		httpSession = request.getSession(false);
		
		listInSession = (List) httpSession.getAttribute("LIST_CUSTOMER_PURCHASE_PRODUCTS");		
		if(listInSession == null){
			listInSession = new ArrayList(0);
			httpSession.setAttribute("LIST_CUSTOMER_PURCHASE_PRODUCTS", listInSession);
		}
		
		form.reset(mapping, request);		
		return mapping.findForward(DEFAULT);
	}
}
